<?php
$ext    = isset($_GET['ext'])?  $_GET['ext']  : '';
$file   = isset($_GET['file'])? $_GET['file'] : '';

$file   = str_replace("..","",$file);


if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) 
{
    @ob_start("ob_gzhandler");
}

$maxAge         = 604800;
$mtimestr       = gmdate ("D, d M Y H:i:s", time() + $maxAge) . " GMT";
$lastmodified   = gmdate ("D, d M Y H:i:s", time() - 86400) . " GMT";
$tag            = "1851417-352-496686cdd766b";

if($_SERVER['HTTP_IF_MODIFIED_SINCE']==$lastmodified && $_SERVER['HTTP_IF_NONE_MATCH']==$tag)
{
    //header("HTTP/1.1 304",true,304);
    //exit;
}

header("Cache-Control: max-age=".$maxAge, true);
header("Last-Modified: ".$lastmodified,true);
header("Etag: $tag",true);
header ("expires: " . $mtimestr,true);


if($ext=="css")
{
    $pathfile   = "styles/".$file;
    header("content-type: text/css",true);  
    if($file=="all.css")
    {
        echo @file_get_contents("styles/style.css");
    }else
    {
        echo @file_get_contents($pathfile);
    }    
}
else if($ext=="js")
{
    $pathfile   = "javascript/".$file;
    header("content-type: text/javascript",true);
    if($file=="main.js")
    {
        echo @file_get_contents($pathfile);
        echo ";";
        echo @file_get_contents("javascript/ajax.js");
        echo ";";
        echo @file_get_contents("javascript/anami.js");
    }else
    {
        echo @file_get_contents($pathfile);
    }  
}
else if($ext=="img")
{
    $pathfile   = "images/".$file;
    //header("content-type: text/javascript");
    echo @file_get_contents($pathfile);
}

?>